#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QColorDialog>
#include <QDebug>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    resize(400,300);
    //创建一个按钮，通过按钮绑定槽函数来打开颜色对话框
    QPushButton* button = new QPushButton("通过按钮获取对话框",this);
    QColorDialog* cdialog = new QColorDialog(this);
    connect(button,&QPushButton::clicked,[=](){
        //给颜色对话框设置初始值
        QColor color = cdialog->getColor(QColor(255,0,0));
        qDebug() << "red : " << color.red();
        qDebug() << "red : " << color.green();
        qDebug() << "red : " << color.blue();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

